{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Richest Customer Wealth"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #matrix"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #矩阵"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: maximumWealth"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #最富有客户的资产总量"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个 <code>m x n</code> 的整数网格 <code>accounts</code> ，其中 <code>accounts[i][j]</code> 是第 <code>i​​​​​<sup>​​​​​​</sup>​</code> 位客户在第 <code>j</code> 家银行托管的资产数量。返回最富有客户所拥有的 <strong>资产总量</strong> 。</p>\n",
    "\n",
    "<p>客户的 <strong>资产总量</strong> 就是他们在各家银行托管的资产数量之和。最富有客户就是 <strong>资产总量</strong> 最大的客户。</p>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>accounts = [[1,2,3],[3,2,1]]\n",
    "<strong>输出：</strong>6\n",
    "<strong>解释：</strong>\n",
    "<code>第 1 位客户的资产总量 = 1 + 2 + 3 = 6\n",
    "第 2 位客户的资产总量 = 3 + 2 + 1 = 6\n",
    "</code>两位客户都是最富有的，资产总量都是 6 ，所以返回 6 。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>accounts = [[1,5],[7,3],[3,5]]\n",
    "<strong>输出：</strong>10\n",
    "<strong>解释：</strong>\n",
    "<code>第 1 位客户的资产总量</code> = 6\n",
    "<code>第 2 位客户的资产总量</code> = 10 \n",
    "<code>第 3 位客户的资产总量</code> = 8\n",
    "第 2 位客户是最富有的，资产总量是 10</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>accounts = [[2,8,7],[7,1,3],[1,9,5]]\n",
    "<strong>输出：</strong>17\n",
    "</pre>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>m == accounts.length</code></li>\n",
    "\t<li><code>n == accounts[i].length</code></li>\n",
    "\t<li><code>1 &lt;= m, n &lt;= 50</code></li>\n",
    "\t<li><code>1 &lt;= accounts[i][j] &lt;= 100</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [richest-customer-wealth](https://leetcode.cn/problems/richest-customer-wealth/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [richest-customer-wealth](https://leetcode.cn/problems/richest-customer-wealth/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[[1,2,3],[3,2,1]]', '[[1,5],[7,3],[3,5]]', '[[2,8,7],[7,1,3],[1,9,5]]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        result = 0\n",
    "        for i in accounts:\n",
    "            s = sum(i)\n",
    "            result = max(result, s)\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        '''\n",
    "        # 方法1\n",
    "        richist = 0\n",
    "        for account in accounts:\n",
    "            richist = max(sum(account), richist)\n",
    "        return richist\n",
    "        '''\n",
    "        # 方法2: 一行解法\n",
    "        return max([sum(account) for account in accounts])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        return max(sum(i) for i in accounts)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        return max([sum(account) for account in accounts])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        max = 0\n",
    "        for i in range(len(accounts)):\n",
    "            temp = 0\n",
    "            for j in range(len(accounts[i])):\n",
    "                temp += accounts[i][j]\n",
    "            if temp > max:\n",
    "                max = temp;\n",
    "        return max\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        zc=[]\n",
    "        for i in range(len(accounts)):\n",
    "            zc.append(sum(accounts[i]))\n",
    "        a=max(zc)\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        list1 = []\n",
    "        for n in range(len(accounts)):\n",
    "            list1.append(sum(accounts[n]))\n",
    "        num = max(list1)\n",
    "        return num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        return max(map(sum, accounts))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        m=len(accounts)\n",
    "        a=[]\n",
    "        max=0\n",
    "        for i in range(m):\n",
    "            sum=0\n",
    "            n=len(accounts[i])\n",
    "            for j in range(n):\n",
    "                sum=sum+accounts[i][j]\n",
    "                a.append(sum)\n",
    "        for i in range(len(a)):\n",
    "            if a[i]>max:\n",
    "                max=a[i]\n",
    "        return max\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        n=[]\n",
    "        for ii in accounts:\n",
    "            sum=0\n",
    "            for jj in ii:\n",
    "                sum+=jj\n",
    "            n.append(sum)\n",
    "        n.sort()\n",
    "        return n[-1]\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        return max(map(sum, accounts))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumWealth(self, accounts: List[List[int]]) -> int:\n",
    "        s=0\n",
    "        for i in accounts:\n",
    "            a=sum(i)\n",
    "            if a>s:\n",
    "                s=a\n",
    "        return s"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
